package flc.ast.utils;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.SPUtils;
import com.google.gson.reflect.TypeToken;

import java.util.List;

import flc.ast.bean.MyAlbumBean;
import flc.ast.bean.TransferRecordBean;


public class AppSpUtils {
    private static final String SP_NAME = "appCollSp";
    private static final SPUtils sSpUtils = SPUtils.getInstance(SP_NAME);

    //图片
    public static void saveTransferPicList(List<TransferRecordBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_transfer_pic_list, json);
    }

    public static List<TransferRecordBean> getTransferPicList() {
        String json = sSpUtils.getString(Key.key_transfer_pic_list);
        return GsonUtils.fromJson(json, new TypeToken<List<TransferRecordBean>>() {
        }.getType());
    }

    public static void saveReceivePicList(List<TransferRecordBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_receive_pic_list, json);
    }

    public static List<TransferRecordBean> getReceivePicList() {
        String json = sSpUtils.getString(Key.key_receive_pic_list);
        return GsonUtils.fromJson(json, new TypeToken<List<TransferRecordBean>>() {
        }.getType());
    }

    //视频
    public static void saveTransferVideoList(List<TransferRecordBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_transfer_video_list, json);
    }

    public static List<TransferRecordBean> getTransferVideoList() {
        String json = sSpUtils.getString(Key.key_transfer_video_list);
        return GsonUtils.fromJson(json, new TypeToken<List<TransferRecordBean>>() {
        }.getType());
    }

    public static void saveReceiveVideoList(List<TransferRecordBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_receive_video_list, json);
    }

    public static List<TransferRecordBean> getReceiveVideoList() {
        String json = sSpUtils.getString(Key.key_receive_video_list);
        return GsonUtils.fromJson(json, new TypeToken<List<TransferRecordBean>>() {
        }.getType());
    }

    //音频
    public static void saveTransferAudioList(List<TransferRecordBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_transfer_audio_list, json);
    }

    public static List<TransferRecordBean> getTransferAudioList() {
        String json = sSpUtils.getString(Key.key_transfer_audio_list);
        return GsonUtils.fromJson(json, new TypeToken<List<TransferRecordBean>>() {
        }.getType());
    }

    public static void saveReceiveAudioList(List<TransferRecordBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_receive_audio_list, json);
    }

    public static List<TransferRecordBean> getReceiveAudioList() {
        String json = sSpUtils.getString(Key.key_receive_audio_list);
        return GsonUtils.fromJson(json, new TypeToken<List<TransferRecordBean>>() {
        }.getType());
    }

    //应用
    public static void saveTransferAppList(List<TransferRecordBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_transfer_app_list, json);
    }

    public static List<TransferRecordBean> getTransferAppList() {
        String json = sSpUtils.getString(Key.key_transfer_app_list);
        return GsonUtils.fromJson(json, new TypeToken<List<TransferRecordBean>>() {
        }.getType());
    }

    public static void saveReceiveAppList(List<TransferRecordBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_receive_app_list, json);
    }

    public static List<TransferRecordBean> getReceiveAppList() {
        String json = sSpUtils.getString(Key.key_receive_app_list);
        return GsonUtils.fromJson(json, new TypeToken<List<TransferRecordBean>>() {
        }.getType());
    }

    //联系人
    public static void saveTransferContactsList(List<TransferRecordBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_transfer_contacts_list, json);
    }

    public static List<TransferRecordBean> getTransferContactsList() {
        String json = sSpUtils.getString(Key.key_transfer_contacts_list);
        return GsonUtils.fromJson(json, new TypeToken<List<TransferRecordBean>>() {
        }.getType());
    }

    public static void saveReceiveContactsList(List<TransferRecordBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_receive_contacts_list, json);
    }

    public static List<TransferRecordBean> getReceiveContactsList() {
        String json = sSpUtils.getString(Key.key_receive_contacts_list);
        return GsonUtils.fromJson(json, new TypeToken<List<TransferRecordBean>>() {
        }.getType());
    }

    //相册
    public static void saveAlbumList(List<MyAlbumBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_album_list, json);
    }

    public static List<MyAlbumBean> getAlbumList() {
        String json = sSpUtils.getString(Key.key_album_list);
        return GsonUtils.fromJson(json, new TypeToken<List<MyAlbumBean>>() {
        }.getType());
    }

    interface Key {

        //图片
        String key_transfer_pic_list = "key_transfer_pic_list";
        String key_receive_pic_list = "key_receive_pic_list";

        //视频
        String key_transfer_video_list = "key_transfer_video_list";
        String key_receive_video_list = "key_receive_video_list";

        //音频
        String key_transfer_audio_list = "key_transfer_audio_list";
        String key_receive_audio_list = "key_receive_audio_list";

        //应用
        String key_transfer_app_list = "key_transfer_app_list";
        String key_receive_app_list = "key_receive_app_list";

        //联系人
        String key_transfer_contacts_list = "key_transfer_contacts_list";
        String key_receive_contacts_list = "key_receive_contacts_list";

        //相册
        String key_album_list = "key_album_list";

    }
}